﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KVB.Common;
using Customer_Profile.eCard.DBDao;

namespace Customer_Profile.eCard.Agent
{
    public partial class SpreadReward : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                bindRatio();
            }
        }

        private void bindRatio()
        {
            try
            {
                string s_ratio = SaleAgentDao.getSpreadRatio();
                txtSpreadRatio.Value = s_ratio;
            }
            catch (Exception ex)
            {
                Log.WriteDefaultLog("bindAgentProd", ex.ToString());
            }
        }
        protected void ibtnAdd_ServerClick(object sender, EventArgs e)
        {           
            try
            {
                decimal ratio = decimal.Parse(txtSpreadRatio.Value.Trim());

                bool bok = SaleAgentDao.SpreadRatioUpdate(ratio);
                if (bok)
                    Response.Write("<script language=javascript>alert('设置成功');</script>");
                else
                    Response.Write("<script language=javascript>alert('设置失败');</script>");
            }
            catch (Exception ex)
            {
                Log.WriteDefaultLog("SpreadReward.ibtnAdd_ServerClick", ex.ToString());
                Response.Write("<script language=javascript>alert('" + ex.ToString() + "');</script>");
            }
        }
    }
}